export default class Map extends Laya.Sprite {

    static getInstance(data) {
        if (!this.instance||this.instance.destroyed) this.instance = new this(data);
        return this.instance;
    }

    constructor(data) {
        super();
        this.init(data);
    }

    init() {
        this.size(1510*2, 790*2);
        this.bg = new Laya.Image("assets/map/2/bg.jpg");
        this.bg.scale(2, 2);
        this.addChildAt(this.bg, 0);
    }

    setFocus(x, y) {
        let offX = Laya.stage.width/2 - x;
        let offY = Laya.stage.height/2 - y;
        
        offX = Math.max(Laya.stage.width-this.width, Math.min(0, offX));
        offY = Math.max(Laya.stage.height-this.height, Math.min(0, offY));

        this.pos(offX, offY);
    }

}